package net.ankao.org.easylock.config;

import net.ankao.org.easylock.core.EasyLockTemplate;
import net.ankao.org.easylock.core.SingleEasyLockTemplate;
import net.ankao.org.easylock.utils.EasyLockUtil;
import org.redisson.api.RedissonClient;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 * EasyLockConfiguration
 * </p>
 *
 * @author lilu
 * @since 2022/3/28
 */
@EnableCaching
@Configuration
public class EasyLockConfiguration {

    @Bean
    public EasyLockTemplate distributedLockTemplate(RedissonClient redissonClient) {
        return new SingleEasyLockTemplate(redissonClient);
    }

    @Bean
    public EasyLockUtil distributedLockUtils(RedissonClient redissonClient) {
        return new EasyLockUtil(redissonClient);
    }
}
